<template>
  <div>
    <SearchTable
      v-bind="$attrs"
      :searchSchame="searchSchame"
      :tableColumns="tableColumns"
      :api="listAllDeptCardNum"
      ref="tableRef"
    ></SearchTable>
    <DepartmentDetail ref="departmentDetail" />
  </div>
</template>

<script lang="ts" setup>
import SearchTable from '@/components/table/SearchTable.vue'
import { generateTableColumn, searchSchame } from './util'
import { listAllDeptCardNum } from '@/api/home'
import DepartmentDetail from '@/views/events/deal/DepartmentDetail.vue'
import { useTemplateRef } from 'vue'

const departmentDetail =
  useTemplateRef<InstanceType<typeof DepartmentDetail>>('departmentDetail')

const tableColumns = generateTableColumn(tableColumnClick)

// 列表项点击
function tableColumnClick(columnType: string, row: Record<string, any>) {
  if (columnType === 'unitForShort') {
    departmentDetail?.value?.show(row.unitId)
  }
}
</script>
